﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>XiugaiPwd</title>
    <link href="~/Content/bootstrap.css" rel="stylesheet" />
    <link href="~/Content/XiugaiPwd.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.10.2.js"></script>
</head>
<body>
    <div>
        <table class="table table-hover" style="width:800px;margin:0 auto;margin-top:100px">
            <tr>
                <td><span style="color:red">*</span>登录手机号：</td>
                <td><input name="Phone" id="Phone" type="text" class="btn-input" value="@Session["Name"]" disabled="disabled"/></td>
            </tr>
            <tr>
                <td><span style="color:red">*</span>原密码</td>
                <td><input name="Pwd" id="Pwd" type="text" class="btn-input" placeholder="请输入当前密码"/></td>
            </tr>
            <tr>
                <td><span style="color:red">*</span>新密码</td>
                <td><input name="NewPwd" id="NewPwd" type="text" class="btn-input" placeholder="请输入新密码"/></td>
            </tr>
            <tr>
                <td><span style="color:red">*</span>确认密码</td>
                <td><input name="affirmPwd" id="affirmPwd" type="text" class="btn-input" placeholder="请输入新密码"/></td>
            </tr>
            <tr>
                <td></td>
                <td><input id="sumbtn" type="button" value="设置密码" class="btns" /></td>
            </tr>
        </table>
    </div>
</body>
</html>
<script>
    
    $("#Pwd").change(function () {
        $.ajax({
            url: "/Login/PwdQueren",
            type: "post",
            data: {Phone:$('#Phone').val(), Pwd: $("#Pwd").val() },
            success: function (data) {
                if (data > 0) {
                  
                }
                else if (data == -1) {
                    alert("原密码不对");
                    $("#Pwd").val("");
                    $("#Pwd").focus();
                }
            }
        })
    })
    $("#sumbtn").click(function () {
        $.ajax({
            url: "/login/XiugaiPwd",
            type: "post",
            data: { Phone: $('#Phone').val(), Pwd: $("#Pwd").val(), NewPwd: $("#NewPwd").val(), affirmPwd: $("#affirmPwd").val() },
            success: function (data) {
                if (data > 0) {
                    alert("修改成功");
                }
                if (data == -1) {
                    alert("请填写完整信息");

                }
                else if (data == -2) {
                    alert("两次密码输入不一致");
                    $("#NewPwd").val("");
                    $("#affirmPwd").val("");
                    $("#NewPwd").focus();
                }
             
               
            }
        })
    })
</script>
